package thirdassigment;
import java.io.File;
//import java.util.Scanner;
public class DirView implements ICommandExecutor{
	private static ICommandExecutor instance;
	public void execute (String enterstr)  
	  {
	    
		String[] str_mas = enterstr.split(" ");
		//String command = str_mas[0];
		String directory = str_mas[1];
	    //String SearchWord = str_mas[2];
		
	    File f1 = new File(directory);
	   
	    if (f1.isDirectory()) 
	    { 
	      System.out.println("Directory of " + directory);
	      String s[] = f1.list();
	      for ( int i=0; i < s.length; i++) 
	      {
	        File f = new File(directory + "/" + s[i]);
	          if (f.isDirectory())
	           {  
	        	  System.out.println(s[i] +  " is a folder");
	           } 
	          else 
	           {
	        	  System.out.println(s[i] + " is a file" +" Size-" + f.length());
	           } 
	      } 
	    } 
	    else 
	    {
	      System.out.println(directory + " is not a directory");
	    } 
	  }
	
	
	
	
	public static ICommandExecutor getInstance() {
        if(instance==null){
                instance=new DirView();       
                }
        return instance;
}
}
